//headers 
#include<algorithm>
#include<cassert>
#include<cstdio>
#include<deque>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<deque>
#include<set>
#include<string>
#include<sstream>
#include<stack>
#include<streambuf>
#include<vector>
using namespace std;

//macros
#define LET(x,a) typeof(a) x(a)
#define FOR(i,a,n) for(LET(i,a);i!=n;i++)
#define REP(i,n) FOR(i,0,n)
#define sz size()
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define dbge(x) cout<<#x<<"->"<<x<<endl;
#define PRINT(x) { REP(tmp,x.sz) cout<<x[tmp]<<" "; cout<<endl; }
#define OUT(x) x<<" "

#define LL long long 
#define VI vector<int>
#define VS vector<string>
#define VVI vector< vector<int> >

const int INF = (int) 1e8;

//code of suren

// maximal sub rectangle problem 

int main(){
	int N; cin>>N;
	

	VI _(N+1,0);
	VVI a(N+1,_),pre(N,_);

	FOR(i,1,N+1) FOR(j,1,N+1) cin>>a[i][j]; pre=a; 
	FOR(i,1,N+1) FOR(j,1,N+1) pre[i][j] += pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1];
/*
	REP(i,N+1) PRINT(a[i]); cout<<endl;
	REP(i,N+1) PRINT(pre[i]);
*/
	int max = pre[1][1];
	FOR(x,1,N+1) FOR(y,1,N+1) 
		FOR(i,x,N+1) FOR(j,y,N+1) {
			int temp = pre[i][j] - pre[x-1][j] - pre[i][y-1] + pre[x-1][y-1];
			if(temp>max) max=temp;
	}
	
	cout<<max<<endl;
  return 0;
}






























